"use strict";

const Service = require("egg").Service;

class CategoryService extends Service {
  async update(category, id) {
    return await this.ctx.model.Category.update(category, {
      where: { categoryId: id },
    });
  }

  async destroy(id) {
    return await this.ctx.model.Category.destroy({
      where: { categoryId: id },
    });
  }

  /**
   * 根据id获取分类
   * @param {*} id 分类id
   */
  async getCategory(id) {
    return this.ctx.model.Category.findByPk(id);
  }
}

module.exports = CategoryService;
